/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.frankkie.parcdroidprj;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.view.View;

/**
 *
 * @author frankkie
 */
public class SensorTesterDraw extends View {

    Path mPath = new Path();
    Paint paint = new Paint();

    public SensorTesterDraw(Context context) {
        super(context);

        mPath.moveTo(0, -25);
        mPath.lineTo(-10, 30);
        mPath.lineTo(0, 25);
        mPath.lineTo(10, 30);
        mPath.close();
    }

    @Override
    protected void onDraw(Canvas canvas) {
        System.out.println("DrawDinges.onDraw");

        canvas.drawColor(Color.WHITE);

        //TEMP
        //paint.setAntiAlias(false);
        paint.setStyle(Paint.Style.FILL);
        paint.setColor(Color.RED);
        canvas.drawRect(30, 120, 70, 150, paint);
        paint.setStyle(Paint.Style.STROKE);
        paint.setColor(Color.BLACK);
        canvas.drawRect(30, 100, 70, 150, paint);
        float[] tempV = SensorTester.tempValues;
        if (tempV != null && tempV.length >= 3) {
            String deTextVanTemperatuur = "TEMP: ";
            for (int a = 0; a < tempV.length; a++) {
                if (a != tempV.length - 1) {
                    deTextVanTemperatuur += (tempV[a] + ",");
                } else {
                    deTextVanTemperatuur += (tempV[a] + "");
                }
            }
            canvas.drawText(deTextVanTemperatuur, 100, 150, paint);
        } else {
            canvas.drawText("Geen Temp...", 100, 150, paint);
        }

        canvas.drawText("Accel: " + SensorTester.accelValues[0] + ", " + SensorTester.accelValues[1] + ", " + SensorTester.accelValues[2], 100, 200, paint);

        canvas.drawText("Magnet: " + SensorTester.magnetValues[0] + ", " + SensorTester.magnetValues[1] + ", " + SensorTester.magnetValues[2], 100, 250, paint);

        //COMPASS
        int cx = 50;
        int cy = 50;
        paint.setAntiAlias(true);
        paint.setColor(Color.BLACK);
        paint.setStyle(Paint.Style.FILL);
        float[] compassV = SensorTester.compassValues;

        if (compassV != null &&
                compassV.length >= 3) {
            canvas.drawText("Compass (" + compassV[0] + "," + compassV[1] + "," + compassV[2] + ")", 90, 50, paint);
        } else {
            canvas.drawText("Compass", 100, 50, paint);
        }
        canvas.translate(cx, cy);
        if (SensorTester.compassValues != null) {
            canvas.rotate(-SensorTester.compassValues[0]);
        }
        canvas.drawPath(mPath, paint);

        //invalidate();
    }
}
/*
 *
 * public class SampleView extends View {
public Paint   mPaint = new Paint();
public Path    mPath = new Path();
public boolean mAnimate;
public long    mNextTime;

public SampleView(Context context) {
super(context);

// Construct a wedge-shaped path
mPath.moveTo(0, -50);
mPath.lineTo(-20, 60);
mPath.lineTo(0, 50);
mPath.lineTo(20, 60);
mPath.close();
}

@Override protected void onDraw(Canvas canvas) {
Paint paint = mPaint;

canvas.drawColor(Color.WHITE);

paint.setAntiAlias(true);
paint.setColor(Color.BLACK);
paint.setStyle(Paint.Style.FILL);

int w = canvas.getWidth();
int h = canvas.getHeight();
int cx = w / 2;
int cy = h / 2;

canvas.translate(cx, cy);
if (mValues != null) {
canvas.rotate(-mValues[0]);
}
canvas.drawPath(mPath, mPaint);
}

@Override
protected void onAttachedToWindow() {
mAnimate = true;
super.onAttachedToWindow();
}

@Override
protected void onDetachedFromWindow() {
mAnimate = false;
super.onDetachedFromWindow();
}
}
 *
 */
